Repository navigation
Add the column and sort editors - #3431
Conversation
These editors are not on the search page yet. Removing a column now drops only that field from a multi-field sort, including names that contain a comma. Co-authored-by: Cursor <cursoragent@cursor.com>
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
6 finding(s): 🔴 0 critical · 🟠 1 major · 🔵 5 minor 1 posted as inline comment(s) on the changed lines. 5 listed below. Findings outside the changed lines5 minor
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
Deep ReviewScope: ✅ No critical issues found. No P0/P1 defects surfaced: the new clause parsing ( 🟡 P2 — recommended
🔵 P3 nitpicks (3)
Reviewers (3 returned): maintainability, project-standards, learnings-researcher. The orchestrator independently verified the prior-review-comment threads against the current source (confirming the Testing gaps: No test covers No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
E2E Test Results✅ All tests passed • 457 passed • 1 skipped • 1337s
Tests ran across 4 shards in parallel. |
🦋 Changeset detectedLatest commit: 91fed66 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
[Medium impact] The PR appears safe to merge, with two non-blocking usability issues left from the previous review.
|
| const sensors = useSensors( | ||
| useSensor(MouseSensor, { activationConstraint: { distance: 8 } }), | ||
| useSensor(TouchSensor, { | ||
| activationConstraint: { delay: 200, tolerance: 5 }, | ||
| }), | ||
| ); |
There was a problem hiding this comment.
Keyboard users cannot reorder columns
The reorder handles have no keyboard controls because sensors contains only MouseSensor and TouchSensor. Keyboard users can focus the handles but cannot move a column in the Fields tab. Add KeyboardSensor with sortableKeyboardCoordinates.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Apply stays off with nothing selected. A map key already in the list cannot be added again, removing a duplicated column drops one row, and a comma inside a backtick-quoted sort name stays one field. Co-authored-by: Cursor <cursoragent@cursor.com>
Greptile reviewed
|
| export function splitClauseList(input: string): string[] { | ||
| const { sqlWithReplacements, replacements } = | ||
| replaceBacktickedIdentifiers(input); | ||
| return splitAndTrimWithBracket(sqlWithReplacements).map(part => |
There was a problem hiding this comment.
🔵 minor — Only the new code handles backtick names; DBSearchPage still splits a backtick name like a,b in two
splitClauseList handles backticks only for the new editors and orderByAfterRemovingSelectItem. DBSearchPage.tsx:1834 (displayedColumns, used by toggleColumn) still calls splitAndTrimWithBracket. Toggling a column from the table header turns `a,b` into `a and b`, and writes that broken SELECT back. The Columns editor would keep the same SELECT whole. Make splitAndTrimWithBracket in common-utils/src/core/utils.ts skip commas inside backticks, as it already does for ' and ". Every caller then gets the fix, and splitClauseList can go.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| <SegmentedControl | ||
| size="xs" | ||
| fullWidth | ||
| value={mode} |
There was a problem hiding this comment.
🔵 minor — ClausePopover is a second copy of the Group by popover shell
SearchGroupBySelect.tsx:109-189 already has the same shell: a split button target, a Fields/SQL SegmentedControl, the draft reset on open, and Reset to default / Apply buttons. Now that ClausePopover exists, the two will drift; they already differ in Cancel vs Clear and in the subtle vs link variant for Reset. Move SearchGroupBySelect onto ClausePopover so all three toolbar clauses share one shell.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
The ad hoc filter helpers drop DateTime types. These pickers need Timestamp. Co-authored-by: Cursor <cursoragent@cursor.com>
jordan-simonovski
left a comment
There was a problem hiding this comment.
I've left a couple of comments to address some DRY stuff, but otherwise this looks good. Lmk when you've resolved those and I'm happy to approve!
Columns and Sort store a default the same way. The pickers reuse the ad hoc key helpers and keep DateTime by passing their own type check. Co-authored-by: Cursor <cursoragent@cursor.com>
| // Field discovery is off for some teams, and `useAllFields` then returns | ||
| // [] rather than "still loading". Scalar columns are still known. | ||
| const keys = | ||
| isFieldMetadataDisabled || fields == null |
There was a problem hiding this comment.
🔵 minor — Field-metadata failure leaves the pickers with no options even though the columns are known
useMultipleAllFields (packages/app/src/hooks/useMetadata.tsx:309-316) catches a failed getAllFields and returns fields: [] with an error, so data is [], not null. getSqlSourceKeys([], columns) then returns [] and both Fields tabs have nothing to offer. Fall back to getSqlSourceColumnKeys when the fields list is empty or the result has an error, not only when isFieldMetadataDisabled || fields == null.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| dateRange?: [Date, Date]; | ||
| timestampValueExpression?: string; | ||
| }): string[] { | ||
| const { data: fields, isFieldMetadataDisabled } = useAllFields( |
There was a problem hiding this comment.
🔵 minor — Field options use the live dateRange with no enabled gate, unlike the Group by picker
SearchGroupBySelect (packages/app/src/components/SearchGroupBy/SearchGroupBySelect.tsx:47-55) saves dateRange when the popover opens and passes enabled: opened. Live tail moves dateRange on every refresh, and that refetches the keys and collapses the open list. This hook fetches every field even while the popover is closed. It also changes the query key on every tick, so fields drops to undefined and the options switch to the column-only fallback while the user is picking. Accept enabled and pin the dateRange in the same way.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| * not a separator. Those names are tokenized first so a later join cannot | ||
| * insert a space inside one. The shared splitter stays unaware of backticks. | ||
| */ | ||
| export function splitClauseList(input: string): string[] { |
There was a problem hiding this comment.
🟠 major — Backtick-aware splitting added only for the new editors; the live column toggle still splits a,b apart
splitClauseList wraps splitAndTrimWithBracket with backtick tokenization, but DBSearchPage.tsx:1834 (displayedColumns, used by toggleColumn) and SearchGroupBySelect.tsx:58/78/99 still call splitAndTrimWithBracket directly. On a SELECT such as "Timestamp, a,b, Body", toggling a column from the table header splits it into "a", "b", then joins it back as "a, b", which changes the identifier. The same SELECT now has two splitting rules: the new popover and orderByAfterRemovingSelectItem use one, and the toggle that feeds them uses the other. Move the backtick handling into splitAndTrimWithBracket in common-utils/src/core/utils.ts so every caller gets it, or at least switch displayedColumns to splitClauseList.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
There was a problem hiding this comment.
the live column toggle still splits
a,bapart
Not addressing in this PR: displayedColumns and the Group by splits already call splitAndTrimWithBracket on main. Reverting this PR would not change that toggle. splitClauseList stays a wrapper so the shared splitter does not learn about backticks. Switching the page over belongs with the page mount.
There was a problem hiding this comment.
@jordan-simonovski let me know if I should address this.
There was a problem hiding this comment.
I've created HDX-5797 to address this as a follow-up
jordan-simonovski
left a comment
There was a problem hiding this comment.
Approved. Will tackle the Major finding in a follow up as the bug wasn't introduced by your changes
Summary
Adds the Columns and Sort editors, and the clause parsing they share. The search page does not show them yet; mounting them is the next PR.
Removing a column already updates the sort. When that column is one field in a multi-field sort, only that field is dropped. A comma inside a backtick-quoted name stays inside that field. A sort the parser does not understand, such as
Timestamp DESC NULLS LAST, is left as written.How to reproduce
Starting point:
yarn app:dev:localconnected to the demo server, or the Vercel preview.On
main:On this branch:
orderByAfterRemovingSelectItemandsplitClauseListinpackages/app/src/__tests__/utils.test.ts. The editors are covered by the tests underpackages/app/src/components/SearchResultsToolbar/__tests__/.How to test on Vercel preview
N/A — the editors are not mounted, so nothing new is visible on the search page.
References
Made with Cursor